
package com.hlkj.pay.enums;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import com.hlkj.framework.common.valid.IValidEnum;
import com.hlkj.pay.app.merchant.ext.MerchantExtConstant;

import lombok.Getter;

/**
 * @author HlpayTeam
 * @date 2024/09/25 13:38
 */
public interface MerchantEnum {

    @Getter
    enum ACCESS_STATUS implements IValidEnum
    {

        DRAFT(0, "草稿"),
        SYSTEM_AUTH(Integer.valueOf(MerchantExtConstant.ACCESS_STATUS_SYSTEM_AUTH), "系统鉴权中"),
        SUBMIT(2, "已提交，等待平台审核"),
        SYSTEM_APPROVE(Integer.valueOf(MerchantExtConstant.ACCESS_STATUS_SYSTEM_APPROVE), "系统自动审核中"),
        CHANNEL_WAIT_APPROVE(Integer.valueOf(MerchantExtConstant.ACCESS_STATUS_CHANNEL_WAIT_APPROVE), "系统审核通过等待渠道审核"),
        CHANNEL_APPROVE(Integer.valueOf(MerchantExtConstant.ACCESS_STATUS_CHANNEL_APPROVE),"渠道审核中"),
        WAIT_SIGN(6, "待签约"),
        WAIT_SIGNING(7, "签约中"),
        WAIT_SET(8, "待配置"),
        WAIT_SETTING(9, "配置中"),
        APPROVE_SUCCESS(10, "审核完成"),
        APPROVE_REFUSE(11, "审核驳回"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        ACCESS_STATUS(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static ACCESS_STATUS from(Integer key) {
            ACCESS_STATUS[] values = ACCESS_STATUS.values();
            for (ACCESS_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum REPORT_STATUS implements IValidEnum
    {

        DRAFT(0, "草稿"),
        SUBMIT(1, "已提交，等待平台审核"),
        CHANNEL_WAIT_APPROVE(2, "系统审核通过等待渠道审核"),
        CHANNEL_APPROVE(3, "渠道审核中"),
        WAIT_SIGN(40, "待签约"),
        WAIT_SIGNING(50, "签约中"),
        APPROVE_SUCCESS(60, "审核完成"),
        APPROVE_REFUSE(70, "审核驳回"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        REPORT_STATUS(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static REPORT_STATUS from(Integer key) {
            REPORT_STATUS[] values = REPORT_STATUS.values();
            for (REPORT_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }
    @Getter
    enum REPORT_BANK_STATUS implements IValidEnum
    {
        // 银行报备状态 1=待开户，2=待开户意愿确认，3=正常，4=报备成功，5=处理中，，0=失败
        // INIT:初始化,
        // DOING:处理中
        // FAIL:失败
        // SUCCESS:报备成功
        FAIL(0, "失败"),
        INIT(1, "初始化"),
        VERIFY(2, "待开户意愿确认"),
        SUCCESS(4, "开户成功"),
        DOING(5, "处理中"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        REPORT_BANK_STATUS(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static REPORT_BANK_STATUS from(Integer key) {
            REPORT_BANK_STATUS[] values = REPORT_BANK_STATUS.values();
            for (REPORT_BANK_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum NOTICE_PUBLISH_TYPE implements IValidEnum
    {
        // 0 全平台 1 机构 2 商户

        ALL(0, "全平台"), AGENT(1, "机构"), MERCHANT(2, "商户"),

        ;

        /**
         * code
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        NOTICE_PUBLISH_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static NOTICE_PUBLISH_TYPE from(Integer key) {
            NOTICE_PUBLISH_TYPE[] values = NOTICE_PUBLISH_TYPE.values();
            for (NOTICE_PUBLISH_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum MERCHANT_SN_TYPE implements IValidEnum
    {

        MERCHANT(1, "M", "商户"), AGENT(2, "A", "代理商户"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * code
         */
        private String snPrefix;

        /**
         * 错误提示
         */
        private String desc;

        MERCHANT_SN_TYPE(Integer code, String snPrefix, String desc) {
            this.code = code;
            this.snPrefix = snPrefix;
            this.desc = desc;
        }

        public static MERCHANT_SN_TYPE from(Integer key) {
            MERCHANT_SN_TYPE[] values = MERCHANT_SN_TYPE.values();
            for (MERCHANT_SN_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum MERCHANT_TYPE implements IValidEnum
    {

        PERSONAL(1, "个人"), COMPANY(2, "企业"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        MERCHANT_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static MERCHANT_TYPE from(Integer key) {
            MERCHANT_TYPE[] values = MERCHANT_TYPE.values();
            for (MERCHANT_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum CERT_INFO_TYPE implements IValidEnum
    {

        LEGAL(1, "法人"), CONTACT(2, "联系人信息"), CONTROLLER(3, "实际控制人"), BENEFIT(4, "最终受益人"), SHAREHOLDER(5, "企业控股股东信息"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        CERT_INFO_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static CERT_INFO_TYPE from(Integer key) {
            CERT_INFO_TYPE[] values = CERT_INFO_TYPE.values();
            for (CERT_INFO_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum MERCHANT_COMMON_RELATION_TYPE implements IValidEnum
    {

        ACCESS(1, "进件"), REPORT(2, "报备"),FUND(3, "分账"),;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        MERCHANT_COMMON_RELATION_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static MERCHANT_COMMON_RELATION_TYPE from(Integer key) {
            MERCHANT_COMMON_RELATION_TYPE[] values = MERCHANT_COMMON_RELATION_TYPE.values();
            for (MERCHANT_COMMON_RELATION_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum CARD_TYPE implements IValidEnum
    {

        // 0：对公账户 1：对私法人账户 2：对私非法人账户
        CORPORATE_ACCOUNT(0, "对公账户"),
        PRIVATE_CORPORATE_ACCOUNT(1, "对私法人账户"),
        PRIVATE_NON_CORPORATE_ACCOUNT(2, "对私非法人账户"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        CARD_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static CARD_TYPE from(Integer key) {
            CARD_TYPE[] values = CARD_TYPE.values();
            for (CARD_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum SETTLE_CYCLE implements IValidEnum
    {

        // 1 工作日 2 每日 3 每日到账
        D0(1, "D1-当前日","rtacc"),
        D1(2, "D1-下一个自然日","d1acc"),
        T1(3, "T1-下一个工作日","t1acc"),
        MANUAL(4, "手动结算","manual"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;
        private String payWayCode;

        SETTLE_CYCLE(Integer code, String desc,String payWayCode) {
            this.code = code;
            this.desc = desc;
            this.payWayCode = payWayCode;
        }

        public static SETTLE_CYCLE from(Integer key) {
            SETTLE_CYCLE[] values = SETTLE_CYCLE.values();
            for (SETTLE_CYCLE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum CHANGE_LOG_TYPE
    {

        // 1 用户 2 角色 3 权限 4 组织
        MERCHANT_INFO(1, "商户信息"), MERCHANT_CONFIG(2, "商户配置"), MERCHANT_APP(3, "商户app配置"), MERCHANT_APP_CHANNEL(4, "商户app通道配置"), NOTICE(5, "公告"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String msg;

        CHANGE_LOG_TYPE(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public static CHANGE_LOG_TYPE from(Integer key) {
            CHANGE_LOG_TYPE[] values = CHANGE_LOG_TYPE.values();
            for (CHANGE_LOG_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum APP_CHANNEL_TYPE
    {

        // 1 用户 2 角色 3 权限 4 组织
        MERCHANT_COMMON(2, "普通商户"), MERCHANT_SPECIAL(1, "特约商户"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String msg;

        APP_CHANNEL_TYPE(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public static APP_CHANNEL_TYPE from(Integer key) {
            APP_CHANNEL_TYPE[] values = APP_CHANNEL_TYPE.values();
            for (APP_CHANNEL_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum MERCHANT_SCENE_TYPE
    {

        // 1 用户 2 角色 3 权限 4 组织
        WEB(1, "网站"), PHONE(2, "手机端"), OFFLINE(2, "线下"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String msg;

        MERCHANT_SCENE_TYPE(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public static MERCHANT_SCENE_TYPE from(Integer key) {
            MERCHANT_SCENE_TYPE[] values = MERCHANT_SCENE_TYPE.values();
            for (MERCHANT_SCENE_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum MERCHANT_AUTH_STATUS
    {

        // 0：未申请 1 审核中 2 审核通过 3 待确认联系信息 4 待账户验证 6 已冻结 7 已作废 8 授权成功 9 审核驳回
        NO_APPLY(0, "未申请"),
        APPROVEING(1, "审核中"),
        APPROVE(2, "审核通过"),
        WAIT_CONFIRM(3, "待确认联系信息"),
        WAIT_AUTH(4, "待账户验证"),
        FROZEN(6, "已冻结"),
        CANCEL(7, "已作废"),
        AUTH_SUCCESS(8, "授权成功"),
        REJECT(9, "审核驳回"),
        AUTH_FAIL(10, "授权失败"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String msg;

        MERCHANT_AUTH_STATUS(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public static MERCHANT_AUTH_STATUS from(Integer key) {
            MERCHANT_AUTH_STATUS[] values = MERCHANT_AUTH_STATUS.values();
            for (MERCHANT_AUTH_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum CHANNEL_CONFIG_STATUS
    {

        INIT(0, "初始化"),
        SUBMIT(1, "商户登记"),
        FILE_UPLOAD(3, "文件上传"),
        AUDIT(6, "审核"),
        AUDITING(7, "审核中"),
        SIGN(20, "电子协议签署"),
        SIGN_QUERY(21, "电子协议签署查询"),
        OPEN_PRODUCT(30, "开通产品"),
        SUBMER_APPLY(50, "子商户报备申请"),
        SUBMERINFO(51, "子商户信息查询"),
        WECHAT_CONFIG(60, "微信参数待配置"),
        WECHAT_CONFIGING(61, "微信参数配置中"),
        WECHAT_AUTH(70, "微信待认证"),
        WECHAT_AUTHING(71, "微信认证中"),
        ALIPAY_AUTH(80, "支付宝待认证"),
        ALIPAY_AUTHING(81, "支付宝认证中"),
        FINISH(99, "配置完成"),

        STOP_PROCESS(10000, "结束流程"),
        CONTINUE_APPLY_QUERY(10001, "继续进件查询"),
        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        CHANNEL_CONFIG_STATUS(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static CHANNEL_CONFIG_STATUS from(Integer key) {
            CHANNEL_CONFIG_STATUS[] values = CHANNEL_CONFIG_STATUS.values();
            for (CHANNEL_CONFIG_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return CHANNEL_CONFIG_STATUS.INIT;
        }
    }

    @Getter
    enum REPORT_CHANNEL_CONFIG_STATUS
    {

        INIT(0, "初始化"),
        SUBMIT(1, "商户登记"),
        SIGN(2, "电子协议签署"),
        AUDIT(3, "审核"),
        AUDITING(4, "审核中"),
        SMS_SEND(5, "短信发送"),
        SMS_CODE(6, "短信认证"),
        BANK_STATUS(20, "查询银行电子账户状态"),
        BANK_BALANCE(21, "查询银行电子账户余额"),
        BANK_ALLOT(30, "资金调拨"),
        BANK_ALLOT_QUERY(31, "资金调拨查询"),
        PAYMENT(40, "提现"),
        FINISH(99, "配置完成"),;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        REPORT_CHANNEL_CONFIG_STATUS(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static REPORT_CHANNEL_CONFIG_STATUS from(Integer key) {
            REPORT_CHANNEL_CONFIG_STATUS[] values = REPORT_CHANNEL_CONFIG_STATUS.values();
            for (REPORT_CHANNEL_CONFIG_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return REPORT_CHANNEL_CONFIG_STATUS.INIT;
        }
    }

    @Getter
    enum MERCHANT_ACCESS_QUEST_TYPE
    {

        // 0：未申请 1 审核中 2 审核通过 3 待确认联系信息 4 待账户验证 6 已冻结 7 已作废 8 授权成功 9 审核驳回
        SYSTEM_AUTH(1, "系统鉴权"),
        SYSTEM_APPROVE(2, "系统审核"),
        APPLY(10, "开户申请"),
        APPLY_QUERY(11, "开户查询"),
        SIGN(20, "业务签约"),
        SIGN_QUERY(21, "业务签约查询"),
        BUSINESS_CONFIG(30,"业务参数配置"),
        BUSINESS_CONFIG_QUERY(31, "业务参数配置查询"),
        SYNC_CHANNEL(32, "同步通道配置"),
        WECHAT_CONFIG(50, "微信参数配置"),
        WECHAT_CONFIG_QUERY(51, "微信参数配置查询"),
        WECHAT_AUTH_CONFIG(61, "微信认证配置"),
        WECHAT_AUTH_CONFIG_QUERY(61, "微信认证配置查询"),
        ALIPAY_AUTH_CONFIG(63, "支付宝认证配置查询"),
        ALIPAY_AUTH_CONFIG_QUERY(64, "支付宝认证配置查询"),
        APPROVE_REFUSE(-1,"审核拒绝"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        MERCHANT_ACCESS_QUEST_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static MERCHANT_ACCESS_QUEST_TYPE from(Integer code) {
            MERCHANT_ACCESS_QUEST_TYPE[] values = MERCHANT_ACCESS_QUEST_TYPE.values();
            for (MERCHANT_ACCESS_QUEST_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(code)) {
                    return deliveryType;
                }
            }
            return MERCHANT_ACCESS_QUEST_TYPE.SYSTEM_AUTH;
        }

        public static MERCHANT_ACCESS_QUEST_TYPE from(ACCESS_STATUS accessStatus, CHANNEL_CONFIG_STATUS channelConfigStatus) {

            // 重复进件查询流程流程
            if( accessStatus != MerchantEnum.ACCESS_STATUS.APPROVE_REFUSE &&
                    accessStatus != ACCESS_STATUS.CHANNEL_WAIT_APPROVE &&
                    channelConfigStatus.getCode() == CHANNEL_CONFIG_STATUS.CONTINUE_APPLY_QUERY.getCode()){
                return MERCHANT_ACCESS_QUEST_TYPE.APPLY_QUERY;
            }

             switch (accessStatus) {
                case SYSTEM_AUTH:
                    return SYSTEM_AUTH;
                case SYSTEM_APPROVE:
                    return SYSTEM_APPROVE;
                case CHANNEL_WAIT_APPROVE:
                    return APPLY;
                case CHANNEL_APPROVE:
                    return APPLY_QUERY;
                 case WAIT_SIGN:
                     return SIGN;
                case WAIT_SIGNING:
                    return SIGN_QUERY;
                case WAIT_SET:
                    return BUSINESS_CONFIG;
                case WAIT_SETTING:
                    return BUSINESS_CONFIG_QUERY;
                case APPROVE_SUCCESS:
                    switch (channelConfigStatus) {
                        case INIT:
                        case SUBMIT:
                        case WECHAT_CONFIG:
                            return WECHAT_CONFIG;
                        case WECHAT_CONFIGING:
                            return WECHAT_CONFIG_QUERY;
                        case WECHAT_AUTH:
                            return WECHAT_AUTH_CONFIG;
                        case WECHAT_AUTHING:
                            return WECHAT_AUTH_CONFIG_QUERY;
                        case ALIPAY_AUTH:
                            return ALIPAY_AUTH_CONFIG;
                        case ALIPAY_AUTHING:
                            return ALIPAY_AUTH_CONFIG_QUERY;
                        default:
                            return SYNC_CHANNEL;
                    }
                case APPROVE_REFUSE:
                    return APPROVE_REFUSE;
            }
            return null;
        }
    }

    @Getter
    enum MERCHANT_REPORT_QUEST_TYPE
    {

        // 0：未申请 1 审核中 2 审核通过 3 待确认联系信息 4 待账户验证 6 已冻结 7 已作废 8 授权成功 9 审核驳回
        SYSTEM_AUTH(1, "系统鉴权"),
        SYSTEM_APPROVE(2, "系统审核"),
        APPLY(10, "开户申请"),
        APPLY_QUERY(11, "开户查询"),
        SIGN(20, "业务签约"),
        SIGN_QUERY(21, "业务签约查询"),
        ALLOT(30, "资金调拨"),
        ALLOT_QUERY(31, "资金查询"),
        PAYMENT(40, "提现"),
        SYNC_CHANNEL(99, "同步通道配置"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        MERCHANT_REPORT_QUEST_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static MERCHANT_REPORT_QUEST_TYPE from(Integer code) {
            MERCHANT_REPORT_QUEST_TYPE[] values = MERCHANT_REPORT_QUEST_TYPE.values();
            for (MERCHANT_REPORT_QUEST_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(code)) {
                    return deliveryType;
                }
            }
            return MERCHANT_REPORT_QUEST_TYPE.SYSTEM_AUTH;
        }

        public static MERCHANT_REPORT_QUEST_TYPE from(REPORT_STATUS accessStatus, REPORT_BANK_STATUS reportBankStatus) {
            switch (accessStatus) {
                case CHANNEL_WAIT_APPROVE:
                    return APPLY;
                case CHANNEL_APPROVE:
                    return APPLY_QUERY;
                case WAIT_SIGN:
                    return SIGN;
                case WAIT_SIGNING:
                    return SIGN_QUERY;
                case APPROVE_SUCCESS:
                    switch (reportBankStatus) {
                        case INIT:
                        case DOING:
                        case VERIFY:
                            return APPLY_QUERY;
                        default:
                            return SYNC_CHANNEL;
                    }
            }
            return null;
        }
    }

    @Getter
    enum PROCESS_STATUS
    {

        // 0 待审核 1 审核通过 2 执行中 3 执行完成 4 执行失败 5 审核拒绝 6 交易退票
        INIT(0, "待审核"), APPROVE(1, "审核通过"), DOING(2, "执行中"), SUCCESS(3, "执行完成"), FAIL(4, "执行失败"), REJECT(5, "审核拒绝"), REFUND(6, "交易退票")

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        PROCESS_STATUS(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static PROCESS_STATUS from(Integer key) {
            PROCESS_STATUS[] values = PROCESS_STATUS.values();
            for (PROCESS_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return PROCESS_STATUS.INIT;
        }
    }
    @Getter
    enum REPORT_AMOUNT_STATUS
    {

        // 0 初始化 1 调拨中 2 代付 3 代付执行中 4 代付完成
        INIT(0, "初始化"), DOING(1, "处理中"), SUCCESS(2, "成功"),FAIL(3, "失败"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        REPORT_AMOUNT_STATUS(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static REPORT_AMOUNT_STATUS from(Integer key) {
            REPORT_AMOUNT_STATUS[] values = REPORT_AMOUNT_STATUS.values();
            for (REPORT_AMOUNT_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return REPORT_AMOUNT_STATUS.INIT;
        }
    }
    @Getter
    enum REPORT_AMOUNT_PROCESS_STATUS
    {

        // 0 初始化 1 调拨中 2 代付 3 代付执行中 4 代付完成
        INIT(0, "初始化"), ALLOT(1, "调拨中"), PAYMENT(2, "代付"),DOING(3, "代付执行中"), SUCCESS(4, "代付完成"),FAIL(5, "执行失败"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        REPORT_AMOUNT_PROCESS_STATUS(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static REPORT_AMOUNT_PROCESS_STATUS from(Integer key) {
            REPORT_AMOUNT_PROCESS_STATUS[] values = REPORT_AMOUNT_PROCESS_STATUS.values();
            for (REPORT_AMOUNT_PROCESS_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return REPORT_AMOUNT_PROCESS_STATUS.INIT;
        }
    }
    @Getter
    enum DATA_RELATION_TYPE
    {

        ACCESS(1, "进件"), REPORT(2, "汇电通"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        DATA_RELATION_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static DATA_RELATION_TYPE from(Integer key) {
            DATA_RELATION_TYPE[] values = DATA_RELATION_TYPE.values();
            for (DATA_RELATION_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return DATA_RELATION_TYPE.ACCESS;
        }
    }
    @Getter
    enum MERCHANT_ACCESS_AMOUNT_STATUS
        //1=初始化，2=处理中，3=成功，4=失败，5=人工介入中
    {

        INIT(1, "初始化"),
        DOING(2, "处理中"),
        SUCCESS(3, "成功"),
        FAIL(4, "失败"),
        MANUAL(5, "失败"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        MERCHANT_ACCESS_AMOUNT_STATUS(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static MERCHANT_ACCESS_AMOUNT_STATUS from(Integer key) {
            MERCHANT_ACCESS_AMOUNT_STATUS[] values = MERCHANT_ACCESS_AMOUNT_STATUS.values();
            for (MERCHANT_ACCESS_AMOUNT_STATUS deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return MERCHANT_ACCESS_AMOUNT_STATUS.INIT;
        }
    }

    @Getter
    enum SOURCE_FROM implements IValidEnum
    {

        LURU(1, "手动录入"), COPY(2, "复制"), OPEN_API(3, "开放接口"),
        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        SOURCE_FROM(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static SOURCE_FROM from(Integer key) {
            SOURCE_FROM[] values = SOURCE_FROM.values();
            for (SOURCE_FROM deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return null;
        }
    }

    @Getter
    enum MERCHANT_LOG_TYPE
            //数据类型：1=进件，2=商户，3=报备
    {

        ACCESS(1, "进件"), MERCHANT(2, "商户"),REPORT(3, "报备"),NOT_FOUND(99, "未知操作"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        MERCHANT_LOG_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static MERCHANT_LOG_TYPE from(Integer key) {
            MERCHANT_LOG_TYPE[] values = MERCHANT_LOG_TYPE.values();
            for (MERCHANT_LOG_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return MERCHANT_LOG_TYPE.NOT_FOUND;
        }
    }

    @Getter
    enum MERCHANT_LOG_OPERATE_TYPE
            //操作类型：1=新增，2=修改，3=审核驳回，4=进件驳回，5=审核成功，6=进件成功
    {

        ADD(1, "新增"), EDIT(2, "修改"),APPROVE_REFUSE(3, "审核驳回"),ACCESS_REFUSE(4, "进件驳回"),
        APPROVE_SUCCESS(5, "审核成功"),ACCESS_SUCCESS(6, "进件成功"),NOT_FOUND(99, "未知操作"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        MERCHANT_LOG_OPERATE_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static MERCHANT_LOG_OPERATE_TYPE from(Integer key) {
            MERCHANT_LOG_OPERATE_TYPE[] values = MERCHANT_LOG_OPERATE_TYPE.values();
            for (MERCHANT_LOG_OPERATE_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return MERCHANT_LOG_OPERATE_TYPE.NOT_FOUND;
        }
    }


    @Getter
    enum AUTH_STATUS_TYPE implements IValidEnum
    {

        UNAUTHORIZED(0, "未授权"),
        AUTHORIZED(1, "已授权"),
        CLOSED(2, "已销户"),
        SMID_NOT_EXIST(3, "报备号不存在"),
        AUTHORIZED_FAIL(4, "授权失败"),
        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        AUTH_STATUS_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static AUTH_STATUS_TYPE from(Integer key) {
            AUTH_STATUS_TYPE[] values = AUTH_STATUS_TYPE.values();
            for (AUTH_STATUS_TYPE type : values) {
                if (type.getCode().equals(key)) {
                    return type;
                }
            }
            return null;
        }
    }

    /**
     * 轮询策略 0：系统默认 1 顺序单个 2 随机多个
     */
    @Getter
    enum ROUTE_TYPE implements IValidEnum
    {

        DEFAULT(0, "系统默认"),
        SEQ_SINGLE(1, "顺序单个"),
        RANDOM_MULTIPLE(2, "随机多个"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        ROUTE_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static ROUTE_TYPE from(Integer key) {
            if(key == null){
                return DEFAULT;
            }
            ROUTE_TYPE[] values = ROUTE_TYPE.values();
            for (ROUTE_TYPE deliveryType : values) {
                if (deliveryType.getCode() == key ) {
                    return deliveryType;
                }
            }
            return DEFAULT;
        }
    }

    @Getter
    enum FUND_TYPE implements IValidEnum
    {

        P_CHANNEL(1, "服务商渠道"),
        SP_CHANNEL(2, "商户服务商渠道"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String desc;

        FUND_TYPE(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static FUND_TYPE from(Integer key) {
            if(key == null){
                return P_CHANNEL;
            }
            FUND_TYPE[] values = FUND_TYPE.values();
            for (FUND_TYPE deliveryType : values) {
                if (deliveryType.getCode() == key ) {
                    return deliveryType;
                }
            }
            return P_CHANNEL;
        }
    }
}
